<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<table class="layui-hide" id="" lay-filter=""></table>
<script>
    // $(function(){});
    layui.use(['table', 'layer', 'form', 'laydate'], function () {
        // 开始部分
        var table = layui.table;
        var layer = layui.layer;
        var $ = layui.$;
        var form = layui.form;
        var laydate = layui.laydate;
        // 把表格渲染到页面上
        table.render({
            elem:'#test'
            ,url:'/user/getAllUsers'
            ,toolbar:'#toolbarDemo'
            ,cols:[[
                {type:'checkbox'}
                ,{filed:'id',title:'ID',sort:true}
                ,{filed:'username',title:'用户名'}
                ,{filed:'password',title:'密码'}
                ,{filed:'nickname',title:'公司名称'}
                ,{filed:'address',title:'公司地址'}
                ,{filed:'money',title:'余额'}
                ,{filed:'state',title:'状态',sort: true,templet:function (data) {
                        return data.state=='1'?'正常':'停用';
                    }}
                , {field: 'operate', title: '操作', toolbar: '#user-edit-bar', width: 180}
            ]] ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                ,limit: 2
                ,limits: [2, 4, 6, 8, 10]
            }
        });
        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'add':
                    break;
                case 'delete':
                    var data = table.checkStatus('test').data;
                    break;
            }
            ;
        });


        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'edit-user': {

                    break;
                }

            }
        });

        // 结束部分
    });

</script>